<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">
<h:body>

	<p:dataTable id="majorTable" var="item" paginator="true"
		paginatorTemplate="{CurrentPageReport}  {FirstPageLink}
											{PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
		rows="5" value="#{mbDepartment.majors}" rowKey="#{item.id}"
		selection="#{mbDepartment.majorSelected}" selectionMode="single">

		<p:ajax event="rowSelect" listener="#{mbDepartment.onMajorRowSelect}"
			update=":departmentForm:tabView:majorCommandPanel">
		</p:ajax>

		<p:column>
			<f:facet name="header">
				<h:outputText value="Mã Khoa" />
			</f:facet>
			<h:outputText value="#{item.depId}" />
		</p:column>

		<p:column>
			<f:facet name="header">
				<h:outputText value="Mã Chuyên Ngành" />
			</f:facet>
			<h:outputText value="#{item.majorId}" />
		</p:column>

		<p:column>
			<f:facet name="header">
				<h:outputText value="Tên Chuyên Ngành" />
			</f:facet>
			<h:outputText value="#{item.name}" />
		</p:column>

	</p:dataTable>

	<h:panelGrid id="majorCommandPanel" columns="3">
		<p:commandButton id="addMajor" value="Thêm"
			disabled="#{mbDepartment.editMode == false}" update=":editMajorDlg"
			action="#{mbDepartment.prepareAddMajor}"
			oncomplete="editMajorDlgWidget.show()"></p:commandButton>
		<p:commandButton id="editMajor" value="Sửa"
			action="#{mbDepartment.prepareEditMajor}" update=":editMajorDlg"
			disabled="#{mbDepartment.majorSelected == null}"
			oncomplete="editMajorDlgWidget.show()"></p:commandButton>
		<p:commandButton id="deleteMajor" value="Xóa"
			action="#{mbDepartment.doDeleteMajor}"
			update="majorTable,majorCommandPanel"
			disabled="#{mbDepartment.majorSelected == null}">
		</p:commandButton>
	</h:panelGrid>

	
</h:body>

</html>